package com.main.rentsystem.mapper;

import com.github.pagehelper.Page;
import com.main.rentsystem.pojo.dto.OrderHouseDTO;
import com.main.rentsystem.pojo.entity.House;
import com.main.rentsystem.pojo.dto.HousePageQueryDTO;
import com.main.rentsystem.pojo.entity.OrderHouse;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HouseMapper {
    /**
     * 房屋分页查询
     * @param housePageQueryDTO
     * @return
     */
    Page<House> pageQuery(HousePageQueryDTO housePageQueryDTO);

    /**
     * 预约看房
     * @param orderHouse
     */
    @Insert("insert into order_house (name,specification,feature,size,address,price,order_time,user_id,status) values " +
            "(#{name},#{specification},#{feature},#{size},#{address},#{price},#{orderTime},#{userId},#{status})")
    void InsertHouse(OrderHouse orderHouse);

    /**
     * 预约看房记录
     * @return
     */
    List<OrderHouse> GetHouse(OrderHouseDTO orderHouseDTO);

    /**
     * 新增房屋
     * @param house
     */
    @Insert("insert into house (name,image,specification,feature,size,address,price) values " +
            "(#{name},#{image},#{specification},#{feature},#{size},#{address},#{price})")
    void insertHouse(House house);

    /**
     * 修改房屋
     * @param house
     */
    @Update("UPDATE house set name = #{name}, image = #{image}, specification = #{specification}, " +
            "feature = #{feature}, size = #{size}, address = #{address}, price = #{price} " +
            "where id = #{id}")
    void updateHouse(House house);

    /**
     * 批量删除房屋
     * @param ids
     */
    void deleteBatch(@Param("ids") List<Long> ids);

    /**
     * 修改预约状态
     * @param orderHouseDTO
     */
    @Select("update order_house set status = #{status} where id = #{id}")
    void updateOrderHouse(OrderHouseDTO orderHouseDTO);
}
